import React from 'react';
import ReactDOM from 'react-dom';
import registerServiceWorker from './registerServiceWorker';

import { AppContainer } from 'react-hot-loader';
import { Provider } from 'react-redux';
import { BrowserRouter, Route } from 'react-router-dom';

import { Router } from '@/router';
import store from '@/redux';

import App from '@/pages/index/App';
import './assets/css/index.less';

const render = Component => {
    ReactDOM.render(
        <Provider store={store}>
            <BrowserRouter>
                <AppContainer>
                    <Route path="/" render={() => {
                        return (
                            <Component>
                                <Router />
                            </Component>
                        );
                    }} />
                </AppContainer>
            </BrowserRouter>
        </Provider>
    , document.getElementById('root'))
}
render(App);

if(module.hot){
    module.hot.accept('@/pages/index/App', () => { // 监控根节点如果更新了就触发render
        render(App)
    })
}

registerServiceWorker();
